/*
 * Command.cpp
 *
 *  Created on: Jul 5, 2012
 *      Author: s131705
 */

#include "Command.h"
#include <sstream>

Command::Command()
{
	this->name = "";
	this->arguments = new vector<string>();
	this->infile = "";
	this->outfile = "";
	this->append = false;
}

Command::~Command()
{
	delete arguments;
}

void Command::setName(string n)
{
	if(name.size() > 0)
		arguments->push_back( n );
	else
		name = n;
}

void Command::addArgument( string arg )
{
	arguments->push_back( arg );
}

vector<string>* Command::getArguments()
{
	return arguments;
};

string Command::toString()
{
	stringstream ss (stringstream::in | stringstream::out);
	ss << name << " ";
	for (unsigned int i=0; i<arguments->size(); i++)
	{
		ss << arguments->at(i) << " ";
	}
	return ss.str();
}

void Command::print()
{
	cerr << "Commando: " << name << endl;

	for (unsigned int i=0; i<arguments->size(); i++)
	{
		cerr << "\targ: " << arguments->at(i) << endl;
	}

	cerr << endl;
}
